package com.streamAPI.entity;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;


public class StreamAPIDemo04 {
    /**
     * 引入一个缓冲区buffer,就能实现全系统,全异步,无阻塞,不等待,实时响应
     */
    private static String[] buffer = new String[1];

    public static void main(String[] args) {
        System.out.println(Thread.currentThread());
        System.out.println("111");
        a();
        System.out.println("222");

        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread());
                b("消费数据");
            }
        }).start();
    }

    public static void a(){
        String str = "aaa";
        System.out.println("a做完事");
        buffer[0] = str;
    }

    public static void b(String str){

        str = buffer[0];
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("haha" + str);
    }
}
